package com.njwb.day15.zqzb.ios.io5;

import com.njwb.day15.zqzb.ios.util.Util;

import java.io.*;

public class InputStreamReaderDemo01 {
    public static void main(String[] args) {

        //字节流
        InputStream is =null ;
        //构建转换流
        InputStreamReader irs = null ;

        try {
            File f = new File("C:\\Users\\Administrator\\Desktop\\osw.txt");
            is = new FileInputStream(f);
            //字符流
            irs = new InputStreamReader(is,"gbk");

            //读取
            char[] buffer = new char[10];
            int length  = 0 ;
            while((length=irs.read(buffer))!=-1) {
                String s = new String(buffer,0,length);
                System.out.print(s);
            }


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            Util.closeResource(irs,is);
        }

    }
}
